package com.gjzhao.fmmll.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

/**
 * @Description: SpringSecutiry 配置类
 * @Author: gjzhao
 * @Date Created in 2022-02-08 11:52 下午
 */
@Configuration
@EnableWebSecurity // 开启web的安全访问
public class SpringSecurityConfig extends WebSecurityConfigurerAdapter {

    // 重写configure即可
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        System.out.println("--------");
        //关闭漏洞攻击
        http.csrf().disable();
        http.authorizeRequests() //认证请求
            .anyRequest() //拦截任务访问请求
            .authenticated() //开启springSecurity的账户密码认证
            .and()
            .httpBasic();
    }
}
